package com.kuang.exam.modules.exam.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kuang.exam.modules.exam.entity.ExamLesson;
import com.kuang.exam.modules.exam.mapper.ExamLessonMapper;
import com.kuang.exam.modules.exam.service.ExamLessonService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* <p>
* 考试部门业务实现类
* </p>
*
*/
@Service
public class ExamLessonServiceImpl extends ServiceImpl<ExamLessonMapper, ExamLesson> implements ExamLessonService {

    @Override
    public ExamLesson getByExamId(String examId) {
        QueryWrapper<ExamLesson> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(ExamLesson::getExamId, examId);
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public List<String> listByLessonId(String lessonId) {
        QueryWrapper<ExamLesson> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(ExamLesson::getLessonId, lessonId);
        List<ExamLesson> examLessons = baseMapper.selectList(wrapper);
        List<String> resultList = new ArrayList<>();
        examLessons.forEach(examLesson -> resultList.add(examLesson.getExamId()));
        return resultList;
    }
}
